angular.module("loginApp", ['sessionModule'])
    .controller("loginController", function ($scope, $http) {
        $scope.cu = null;

        $scope.login = function () {
            var req = {
                method: "GET",
                url: "/CHa/user?account=" + $scope.cu.account + "&password=" + $scope.cu.password
            };
            $http(req)
                .then(function (res) {
                    if (res.data != null) {
                        $scope.user={uid:res.data._id,account:res.data.account};
                        window.location.href = "home.html";
                    } else {
                        alert("账户或者密码错误");
                    }

                });
        }
    });

// function login(){
// 	var account = document.getElementById("account").value;
// 	var password = document.getElementById("password").value;
// 	$.get("/CHa/user", { account: account, password: password },
//           function(data){
//             if(data !=null){
// 				window.location.href="home.html";
// 			}else{
// 				alert("账户或者密码错误");
// 			}
//           });
// }